import {reactive} from "vue";

export interface DefaultSorting {
  type: boolean;
  fieldList: string[];
}

export interface Sorting {
  type?: boolean;
  fieldList?: string[];
}

export const defaultSorting: DefaultSorting[] = [
  {
    type: false,
    fieldList: ["id"]
  }
];

export const useSorting = (initialSorting: Sorting[] = []) => {
  const sorting = reactive([...defaultSorting, ...initialSorting]);
  const set = (value: Sorting) => {
    sorting.push(value);
  };

  return {sorting, push: set};
};
